/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;

/**
 *
 * @author Java
 */
public class GetMethod extends Handler {

    private Request req;

    GetMethod(Request req) {
        this.req = req;
    }

    @Override
    public Response readFile() throws FileNotFoundException, IOException {
        byte[] buffer = null;
   
        System.out.println(req.getPathHttp());
        try {
            File f1 = new File(req.getPathHttp());

            InputStream is = new FileInputStream(f1);
            buffer = new byte[(int) f1.length()];

            is.read(buffer);
            is.close();
        } catch (Exception io) {
        }
        Response t = new Response(req.getSoket(), buffer, req.getPathHttp(), req.getId(),req.getConfigBoolean());
        return t;

    }
}
